Package com.fish

Source Code of com.fish.Aqu

package com.fish;

import java.awt.Graphics;
import java.util.ArrayList;

import org.w3c.dom.Document;
import org.w3c.dom.Element;

import com.graphics.Box;
import com.graphics.Camera;
import com.graphics.Shape;
import com.math.Quat;
import com.math.Vector;

public class Aqu extends Shape {


  public int SHAPE_NUM = 8;
  ArrayList<Shape>  shapeS;
  public Shape shape[];
  Box [] boxes;
 
  public Aqu(Camera cam,Vector dim) {
    this.cam = cam;
    d = new Vector(dim);
    p = new Vector();
    r = new Quat();
   
    shapeS = new ArrayList<>();
    boxes = new Box[1];
    shape = new Shape[12];

    this.color = Shape.int2color(8);

    points_num = 8;
    points = new Vector[points_num];

    x = new int[points_num];
    y = new int[points_num];

    build();
    rebuild();

  }

  @Override
  public void build() {
    boxes[0] = new Box(cam, d, p, r, color);
   
//    for(int i = 0;i<SHAPE_NUM/8;i++){
     
//    }
    shape[0] = new Box(cam, new Vector(3,3,d.z-3), p.add(new Vector(d.x,d.y,0)), r, color);
    shape[1] = new Box(cam, new Vector(3,3,d.z-3), p.add(new Vector(d.x,-d.y,0)), r, color);
    shape[2] = new Box(cam, new Vector(3,3,d.z-3), p.add(new Vector(-d.x,d.y,0)), r, color);
    shape[3] = new Box(cam, new Vector(3,3,d.z-3), p.add(new Vector(-d.x,-d.y,0)), r, color);
    shape[4] = new Box(cam, new Vector(d.x+3,3,3), p.add(new Vector(0,d.y,d.z)), r, color);
    shape[5] = new Box(cam, new Vector(d.x+3,3,3), p.add(new Vector(0,d.y,-d.z)), r, color);
    shape[6] = new Box(cam, new Vector(d.x+3,3,3), p.add(new Vector(0,-d.y,d.z)), r, color);
    shape[7] = new Box(cam, new Vector(d.x+3,3,3), p.add(new Vector(0,-d.y,-d.z)), r, color);
    shape[8= new Box(cam, new Vector(3,d.y-3,3), p.add(new Vector(d.x,0,d.z)), r, color);
    shape[9= new Box(cam, new Vector(3,d.y-3,3), p.add(new Vector(d.x,0,-d.z)), r, color);
    shape[10] = new Box(cam, new Vector(3,d.y-3,3), p.add(new Vector(-d.x,0,d.z)), r, color);
    shape[11] = new Box(cam, new Vector(3,d.y-3,3), p.add(new Vector(-d.x,0,-d.z)), r, color);
   
    for(Shape s:shape)
      World.shapes.add(s);
  }

  @Override
  public void rebuild() {
    // TODO Auto-generated method stub

  }

 
  public void show(Graphics g) {

  }

 
  public boolean isInAqu(Vector p){
    return (World.isInBox(this.boxes[0], p));
  }
 
  public Element toXML(Document doc) {
    Element aqu     = doc.createElement("Aqu");
    aqu.setAttribute("dimmention", d+"");
   
    return aqu;
  }

  public static Aqu fromXML(Element e, Camera cam) {
//    Color color =  new Color(Integer.parseInt(e.getAttribute("color")));
    Vector d = Vector.parseVector(e.getAttribute("dimmention"));
//    Vector p = Vector.parseVector(e.getAttribute("position"));
//    Quat r = Quat.parseQuat(e.getAttribute("rotation"));
   
    return new Aqu(cam,d);
  }

}
TOP

Related Classes of com.fish.Aqu

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.